﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace SiteParser.Core
{
	public static class HtmlIteratorFactory
	{
		public static IHtmlIterator CreateIterator(string htmlContent, HtmlNavigationExpression expression) {
			if (expression != null) {
				switch (expression.SelectType) {
					case SelectTypes.Marker:
						return new MarkerHtmlIterator(htmlContent, expression, new HtmlRegexpExpressionBuilder(), expression.MarkerValue);
					case SelectTypes.XPath:
						return new XPathHtmlIterator(htmlContent, expression.XPathValue, new XPathExpressionParser());
					case SelectTypes.AttributeValue:
					case SelectTypes.Constant:
					case SelectTypes.InnerHtml:
					case SelectTypes.OriginalHtml:
					default:
						return new RegexpHtmlIterator(htmlContent, expression, new HtmlRegexpExpressionBuilder());
				}
			}

			return new RegexpHtmlIterator(htmlContent, expression, new HtmlRegexpExpressionBuilder());
		}
	}
}
